Emberveil sourcegame/2006Scape Client/src/main/java/FirePartyhat.java
/** Account-specific black partyhat and animated gold flames for bonds. */
public final class FirePartyhat {
private FirePartyhat() {}
public static boolean wearing(Player player) {
return player != null && "bonds".equalsIgnoreCase(player.name) && player.equipment[0] == 14999 + 512;
}
public static Model recolor(Player player, Model source) {
if (!wearing(player) || source == null) return source;
// Copy face colours; never recolour the shared item model for other players.
Model black = new Model(false, true, true, source);
for (int i=0; i<black.anIntArray1640.length; i++) black.anIntArray1640[i]=8;
return black;
}
public static void draw(int x,int y,int radius,long time) {
if(x<0||y<0)return;
radius=Math.max(4,Math.min(22,radius));
int frame=(int)((time/85L)%12);
for(int tip=0;tip<5;tip++) {
int base=x-radius+tip*radius/2;
int rise=3+radius/3+(frame+tip*3)%4;
for(int up=0;up<rise;up++) {
int sway=up<2?0:((frame+tip+up/2)%3)-1;
int px=base+sway,py=y-up;
int color=up<2?0xfff3ae:up<rise/2?0xffcf40:0xe6a314;
blend(px-1,py,0xffb820,70);blend(px+1,py,0xffb820,70);
blend(px,py,color,235-up*9);
}
}
for(int dx=-radius;dx<=radius;dx++) {
blend(x+dx,y+1,0xffc52a,65);
blend(x+dx,y+2,0xffb31b,35);
}
}
private static void blend(int x,int y,int rgb,int alpha) {
if(x<DrawingArea.topX||x>=DrawingArea.bottomX||y<DrawingArea.topY||y>=DrawingArea.bottomY)return;
int at=x+y*DrawingArea.width,old=DrawingArea.pixels[at],inv=256-alpha;
DrawingArea.pixels[at]=(((rgb&0xff00ff)*alpha+(old&0xff00ff)*inv)&0xff00ff00|
((rgb&0x00ff00)*alpha+(old&0x00ff00)*inv)&0x00ff0000)>>>8;
}
}